package com.benny_driving_dri.act;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.Preference;
import android.preference.PreferenceScreen;

import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.benny_driving_dri.R;

public class SettingPreferenceAct extends SherlockPreferenceActivity {
	public static Handler handler;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		handler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				switch (msg.arg1) {
				case 1:
					break;
				case 2:
					break;
				}
			}

		};
		PackageManager pm = this.getPackageManager();
		String versionName = "";
		addPreferencesFromResource(R.xml.setting);
		try {
			PackageInfo pi = pm.getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES);
			versionName = pi.versionName;
			getPreferenceManager().findPreference(getString(R.string.version_key)).setSummary(getString(R.string.current_version)+versionName);
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			getPreferenceManager().findPreference(
					getString(R.string.version_key)).setSummary(
					getString(R.string.get_version_name_error));
		}
	}

	@Override
	@Deprecated
	public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
			Preference preference) {

		return super.onPreferenceTreeClick(preferenceScreen, preference);
	}

}
